<template>
    <div class="sm-suptaskMidTable">
        <!-- <div class="sm-st-secondbgTitle">
            <p>AO分拣任务列表</p>
        </div> -->
       <div>
            <el-table
            ref="receiveTable"
            size="mini"
            :data="resData"
            style="width: 100%"
            height="190"
            highlight-current-row
            @current-change="tableCurrentChange"
            >
        <!-- <el-table-column type="selection" width="40"> </el-table-column> -->
        <el-table-column type="index" label="序号" width="50" :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="productCode" label="机型" :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="batchNo" label="批次" :show-overflow-tooltip="true" > </el-table-column>
        <el-table-column prop="startPlaneNo" label="架次" :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="aoCode" label="AO编号" width="150" :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="aoName" label="AO名称" width="150" :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="requiredTime" label="要求时间" width="150" :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="state" label="配套状态" :show-overflow-tooltip="true"> </el-table-column>
        <!-- <el-table-column prop="" label="分拣状态" :show-overflow-tooltip="true"> </el-table-column> -->
        <el-table-column prop="remark" label="备注" :show-overflow-tooltip="true"> </el-table-column>
      </el-table>
        <!-- 分页 -->
       <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="pageNumber"
            :page-sizes="[10,20,50,100]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="totalCount">
        </el-pagination>
       </div>
    </div>
</template>
<script>
import { supportingTaskMid } from "@/utils/api.js";
export default {
    name:'SuptaskMidTable',
    data(){
        return {
            // 当前页数
            pageNumber: 1,
            // 数据总个数
            totalCount: 0,
            // 返回的数据数组
            resData: [],
            // 每页数据个数
            pageSize: 20,
            // 确认列表高亮参数
            stableIndex: 0,
            // top传给mid的info
            topMidInfo: "",
            ss: false,
            LastTable:[]
        }
    },
    methods:{
        // 单选表格函数
        tableCurrentChange(val) {
            // 将msTaskAoId 传给lastTable进行查询数据
            if(val == null){
                this.$bus.$emit('smStMidLastNull',this.LastTable)
            }else {
                this.$bus.$emit('smStMidLastInfo',val.msTaskAoId)
            }
            console.log(val)
        },
         // 分页---每页数据条数
        handleSizeChange(val){
            this.pageSize = val;
            supportingTaskMid({
                msTaskPackageId:this.topMidInfo,
                pageParameter: {
                rows: this.pageSize,
                page: this.pageNumber,
                },
            }).then((res) => {
                this.resData = res.data.responseBody.result;
                this.totalCount = res.data.responseBody.pageParameter.totalCount;
            });
        },
        // 分页---页数
        handleCurrentChange(val) {
            this.pageNumber = val;
                supportingTaskMid({
                    msTaskPackageId:this.topMidInfo,
                    pageParameter: {
                    rows: this.pageSize,
                    page: this.pageNumber,
                    },
                }).then((res) => {
                    this.resData = res.data.responseBody.result;
                    this.totalCount = res.data.responseBody.pageParameter.totalCount;
                });
        },
    },
    mounted() {
        // 将msTaskPackageId 传给midTable进行查询数据
        this.$bus.$on('smStTopMidInfo',(e)=>{
            this.topMidInfo = e
                supportingTaskMid({
                    msTaskPackageId:this.topMidInfo,
                    pageParameter: {
                        rows: this.pageSize,
                        page: this.pageNumber
                    },
                }).then((res) => {
                    console.log('配套任务Mid表',res)
                    this.resData = res.data.responseBody.result;
                    this.totalCount = res.data.responseBody.pageParameter.totalCount;
                    
                });
        })
  }
}
</script>
<style scoped>
.sm-suptaskMidTable {
    width: 100%;
    height: 100%;
}
.sm-suptaskMidTable div:nth-child(2) {
    text-align: center;
}
/* .sm-st-secondbgTitle {
  font-size: 16px;
  padding: 5px 2px;
  background-color: rgb(57, 135, 199);
  color: white;
} */
</style>